using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class BK_Passenger
    {
        public int ID { get; set; }
        public int TypeID { get; set; }
        public string Name { get; set; }
        public string FirstName { get; set; }
        public DateTime Birthday { get; set; }
        public string Sex { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public int TK_CountryID { get; set; }
        public int TK_ProvineID { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public string PassportNo { get; set; }
        public int PassportCountryID { get; set; }
        public DateTime PassportExp { get; set; }
        public int NationnalityID { get; set; }
        public DateTime CreatedDate { get; set; }
        public bool IsDeleted { get; set; }

        #region BK_PassengerSelectAll
        public static List<BK_Passenger> BK_PassengerSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_Passenger.BK_PassengerSelectAll(strSearch,top,bottom,ConnectionString);
            List<BK_Passenger> BK_PassengerList = new List<BK_Passenger>();
            while(dr.Read())
            {
                BK_Passenger myBK_Passenger = new BK_Passenger
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    TypeID = !dr.IsDBNull(dr.GetOrdinal("TypeID")) ? (int)dr["TypeID"] : 0,
                    Name = !dr.IsDBNull(dr.GetOrdinal("Name")) ? (string)dr["Name"] : null,
                    FirstName = !dr.IsDBNull(dr.GetOrdinal("FirstName")) ? (string)dr["FirstName"] : null,
                    Birthday = !dr.IsDBNull(dr.GetOrdinal("Birthday")) ? (DateTime)dr["Birthday"] : DateTime.Now,
                    Sex = !dr.IsDBNull(dr.GetOrdinal("Sex")) ? (string)dr["Sex"] : null,
                    Address = !dr.IsDBNull(dr.GetOrdinal("Address")) ? (string)dr["Address"] : null,
                    City = !dr.IsDBNull(dr.GetOrdinal("City")) ? (string)dr["City"] : null,
                    TK_CountryID = !dr.IsDBNull(dr.GetOrdinal("TK_CountryID")) ? (int)dr["TK_CountryID"] : 0,
                    TK_ProvineID = !dr.IsDBNull(dr.GetOrdinal("TK_ProvineID")) ? (int)dr["TK_ProvineID"] : 0,
                    Email = !dr.IsDBNull(dr.GetOrdinal("Email")) ? (string)dr["Email"] : null,
                    Phone = !dr.IsDBNull(dr.GetOrdinal("Phone")) ? (string)dr["Phone"] : null,
                    PassportNo = !dr.IsDBNull(dr.GetOrdinal("PassportNo")) ? (string)dr["PassportNo"] : null,
                    PassportCountryID = !dr.IsDBNull(dr.GetOrdinal("PassportCountryID")) ? (int)dr["PassportCountryID"] : 0,
                    PassportExp = !dr.IsDBNull(dr.GetOrdinal("PassportExp")) ? (DateTime)dr["PassportExp"] : DateTime.Now,
                    NationnalityID = !dr.IsDBNull(dr.GetOrdinal("NationnalityID")) ? (int)dr["NationnalityID"] : 0,
                    CreatedDate = !dr.IsDBNull(dr.GetOrdinal("CreatedDate")) ? (DateTime)dr["CreatedDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                BK_PassengerList.Add(myBK_Passenger);
        }
        dr.Close();
        dr.Dispose();
        return BK_PassengerList;
        }
        #endregion
        #region BK_PassengerSelectRow
        public static BK_Passenger BK_PassengerSelectRow(int ID, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.BK_Passenger.BK_PassengerSelectRow(ID, ConnectionString);
            BK_Passenger bk_passenger = null;

            if(dr.Read())
            {
                bk_passenger= new BK_Passenger
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    TypeID = !dr.IsDBNull(dr.GetOrdinal("TypeID")) ? (int)dr["TypeID"] : 0,
                    Name = !dr.IsDBNull(dr.GetOrdinal("Name")) ? (string)dr["Name"] : null,
                    FirstName = !dr.IsDBNull(dr.GetOrdinal("FirstName")) ? (string)dr["FirstName"] : null,
                    Birthday = !dr.IsDBNull(dr.GetOrdinal("Birthday")) ? (DateTime)dr["Birthday"] : DateTime.Now,
                    Sex = !dr.IsDBNull(dr.GetOrdinal("Sex")) ? (string)dr["Sex"] : null,
                    Address = !dr.IsDBNull(dr.GetOrdinal("Address")) ? (string)dr["Address"] : null,
                    City = !dr.IsDBNull(dr.GetOrdinal("City")) ? (string)dr["City"] : null,
                    TK_CountryID = !dr.IsDBNull(dr.GetOrdinal("TK_CountryID")) ? (int)dr["TK_CountryID"] : 0,
                    TK_ProvineID = !dr.IsDBNull(dr.GetOrdinal("TK_ProvineID")) ? (int)dr["TK_ProvineID"] : 0,
                    Email = !dr.IsDBNull(dr.GetOrdinal("Email")) ? (string)dr["Email"] : null,
                    Phone = !dr.IsDBNull(dr.GetOrdinal("Phone")) ? (string)dr["Phone"] : null,
                    PassportNo = !dr.IsDBNull(dr.GetOrdinal("PassportNo")) ? (string)dr["PassportNo"] : null,
                    PassportCountryID = !dr.IsDBNull(dr.GetOrdinal("PassportCountryID")) ? (int)dr["PassportCountryID"] : 0,
                    PassportExp = !dr.IsDBNull(dr.GetOrdinal("PassportExp")) ? (DateTime)dr["PassportExp"] : DateTime.Now,
                    NationnalityID = !dr.IsDBNull(dr.GetOrdinal("NationnalityID")) ? (int)dr["NationnalityID"] : 0,
                    CreatedDate = !dr.IsDBNull(dr.GetOrdinal("CreatedDate")) ? (DateTime)dr["CreatedDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false,

                };
            }
        dr.Close();
        dr.Dispose();
        return bk_passenger;
        }
        #endregion
        #region BK_PassengerInsertRow
        public static void BK_PassengerInsertRow(int ID, int TypeID, string Name, string FirstName, DateTime Birthday, string Sex, string Address, string City, int TK_CountryID, int TK_ProvineID, string Email, string Phone, string PassportNo, int PassportCountryID, DateTime PassportExp, int NationnalityID, DateTime CreatedDate, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_Passenger.BK_PassengerInsertRow(ID, TypeID, Name, FirstName, Birthday, Sex, Address, City, TK_CountryID, TK_ProvineID, Email, Phone, PassportNo, PassportCountryID, PassportExp, NationnalityID, CreatedDate, IsDeleted, ConnectionString);
        }
        #endregion
        #region BK_PassengerUpdateRow
        public static void BK_PassengerUpdateRow(int ID, int TypeID, string Name, string FirstName, DateTime Birthday, string Sex, string Address, string City, int TK_CountryID, int TK_ProvineID, string Email, string Phone, string PassportNo, int PassportCountryID, DateTime PassportExp, int NationnalityID, DateTime CreatedDate, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_Passenger.BK_PassengerUpdateRow(ID, TypeID, Name, FirstName, Birthday, Sex, Address, City, TK_CountryID, TK_ProvineID, Email, Phone, PassportNo, PassportCountryID, PassportExp, NationnalityID, CreatedDate, IsDeleted, ConnectionString);
        }
        #endregion
        #region BK_PassengerDeleteRow
        public static void BK_PassengerDeleteRow(int ID, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.BK_Passenger.BK_PassengerDeleteRow(ID,ConnectionString);
        }
        #endregion
    }
}
